package 设计模式.proxy.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @功能
 * @创建时间 2020/5/3
 */
public class StarHandler implements InvocationHandler {
    public StarHandler(Star realstar) {
        this.realstar = realstar;
    }

    Star realstar;

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("###########");
        Object o=null;
        System.out.println("真正方法执行");
        System.out.println("面谈，签合同，订票");
        System.err.println(proxy.getClass().equals(method.getDeclaringClass()));
        if(method.getName().equals("sing")){
            o = method.invoke(realstar,args);
        }
  //      method.invoke(realstar,args);
        System.out.println("真正方法执行后");
        System.out.println("收尾");
        return o;
    }
}
